cmake_minimum_required(VERSION 3.12)
project(osg_example)

# 设置C++标准
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)

# 设置CMP0074策略以使用<PackageName>_ROOT变量
if(POLICY CMP0074)
  cmake_policy(SET CMP0074 NEW)
endif()

# 定义OSG_ROOT变量，允许用户在CMake配置时传入路径
set(OSG_ROOT "" CACHE PATH "Path to OpenSceneGraph")
set(OSG_THIRD_PARTY_ROOT "" CACHE PATH "Path to OSG third-party libraries")

# 手动设置包含目录
include_directories(${OSG_ROOT}/include)

# 添加可执行文件
add_executable(osg_example osg_example.cpp)

# 为不同的配置设置链接库
target_link_libraries(osg_example
    debug ${OSG_ROOT}/lib/osgd.lib
    debug ${OSG_ROOT}/lib/osgDBd.lib
    debug ${OSG_ROOT}/lib/osgUtild.lib
    debug ${OSG_ROOT}/lib/osgViewerd.lib
    debug ${OSG_ROOT}/lib/osgGAd.lib
    debug ${OSG_ROOT}/lib/osgTextd.lib
    debug ${OSG_ROOT}/lib/OpenThreadsd.lib
    optimized ${OSG_ROOT}/lib/osg.lib
    optimized ${OSG_ROOT}/lib/osgDB.lib
    optimized ${OSG_ROOT}/lib/osgUtil.lib
    optimized ${OSG_ROOT}/lib/osgViewer.lib
    optimized ${OSG_ROOT}/lib/osgGA.lib
    optimized ${OSG_ROOT}/lib/osgText.lib
    optimized ${OSG_ROOT}/lib/OpenThreads.lib
)

# 设置Visual Studio调试环境变量，只添加OSG路径
set_target_properties(osg_example PROPERTIES
    VS_DEBUGGER_ENVIRONMENT "PATH=${OSG_ROOT}/bin;${OSG_THIRD_PARTY_ROOT}/bin")

# 设置example为启动项目
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT osg_example)
